Verifier: Merkle Proofs
Verifies the Merkle proof component of a transaction proof.
- The tree height
proof.merkleProof.length
must be less thanMERKLE_TREE_HEIGHT_MAX
(256
). - Hash transaction leaf
proof.transaction
to get current hash as the leaf hash. - For height
i
between0
and`proof.merkleProof.length - 1
:- Hash the current hash with its sibling from the Merkle proof. If the
i
th bit ofproof.transactionIndex
is0
, the sibling is on the right. If it's1
, the sibling is on the left.
- Hash the current hash with its sibling from the Merkle proof. If the
- The resultant Merkle root must match
proof.rootHeader.merkleTreeRoot
.
Note: when constructing the tree, the number of nodes at a given level may not be even. In such case, the default value EMPTY_LEAF_HASH
(0x0000000000000000000000000000000000000000000000000000000000000000
) is used as the sibling hash value.